//
//  TrainTicketBannerCell.swift
//  AirTravel
//
//  Created by apple on 2021/8/9.
//

import UIKit

class TrainTicketBannerCell: UITableViewCell {
    
    @IBOutlet weak var jpBUtton: UIButton!
    @IBOutlet weak var backView: UIView!
    /// 查询
    @IBOutlet weak var queryBTN: UIButton!
    /// 高铁
    @IBOutlet weak var railwayBtn: UIButton!
    /// 学生
    @IBOutlet weak var studentsBtn: UIButton!
    @IBOutlet weak var tomorrowLab: UILabel!
    /// 日期
    @IBOutlet weak var dateOfLab: UIButton!
    /// 地址切换
    @IBOutlet weak var switchBtn: UIButton!
    @IBOutlet weak var bannerView: UIView!
    
    @IBOutlet weak var endBtn: UIButton!
    @IBOutlet weak var startBtn: UIButton!
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.backView.layer.cornerRadius = 6
        self.backView.layer.masksToBounds = true
        
        self.queryBTN.layer.cornerRadius = 45/2
        self.queryBTN.layer.masksToBounds = true
        self.switchBtn.addTarget(self, action: #selector(switchBtn(sender:)), for: .touchUpInside)
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    @objc func switchBtn(sender:UIButton) {
        self.endBtn.alpha = 0
        self.startBtn.alpha = 0
        UIView.animate(withDuration: 0.8) {
            self.endBtn.alpha = 1
            self.startBtn.alpha = 1
            let str = self.endBtn.titleLabel?.text
            self.endBtn.setTitle(self.startBtn.titleLabel?.text, for: .normal)
            self.startBtn.setTitle(str, for: .normal)
        }
        
        let momAnimation = CABasicAnimation(keyPath:"transform.rotation.z")
        momAnimation.fromValue=NSNumber(value:0)//左幅度
        momAnimation.toValue=NSNumber(value:Double.pi*2)//右幅度
        momAnimation.duration = 0.8
        momAnimation.repeatCount=1
        sender.layer.add(momAnimation, forKey: "centerLayer")
    }
    
}
